Skip to content

feat: hide type inlay hints for initializations of closures#12263

Merged
bors merged 1 commit into
rust-lang:masterfrom
andylizi:hide-type-hint-closure
May 20, 2022
Merged

feat: hide type inlay hints for initializations of closures#12263
bors merged 1 commit into
rust-lang:masterfrom
andylizi:hide-type-hint-closure

Conversation

@andylizi
Copy link
Copy Markdown
Contributor

@andylizi andylizi commented May 15, 2022

hide_closure_initialization

This PR adds an option to hide the inlay hints for let IDENT_PAT = CLOSURE_EXPR;, which is a somewhat common coding pattern. Currently the inlay hints for the assigned variable and the closure expression itself are both displayed, making it rather repetitive.

In order to be consistent with closure return type hints, only closures with block bodies will be hid by this option.

Personally I'd feel comfortable making it always enabled (or at least when closure return type hints are enabled), but considering the precedent set in #10761, I introduced an off-by-default option for this.

changelog feature: option to hide type inlay hints for let statements that initialize to a closure

Copy link
Copy Markdown
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, I am still thinking about whether to remove the block expression limitation altogether. I only added it as I wasn't sure how helpful they'd be for non block expressions.

Comment thread crates/rust-analyzer/src/config.rs
@hkalbasi
Copy link
Copy Markdown
Member

I would like to see impl Fn, impl FnMut, ... as inlay hint for closures, which I think is a useful data and non trivial in first look. In current state IMO it make sense to enable this by default.

@bors
Copy link
Copy Markdown
Contributor

bors commented May 16, 2022

☔ The latest upstream changes (presumably #12253) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Copy Markdown
Contributor

bors commented May 20, 2022

☔ The latest upstream changes (presumably #12320) made this pull request unmergeable. Please resolve the merge conflicts.

@Veykril
Copy link
Copy Markdown
Member

Veykril commented May 20, 2022

Thanks!

@bors r+

@bors
Copy link
Copy Markdown
Contributor

bors commented May 20, 2022

📌 Commit 2b1c1a9 has been approved by Veykril

@bors
Copy link
Copy Markdown
Contributor

bors commented May 20, 2022

⌛ Testing commit 2b1c1a9 with merge 41388bf...

@bors
Copy link
Copy Markdown
Contributor

bors commented May 20, 2022

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing 41388bf to master...

@bors bors merged commit 41388bf into rust-lang:master May 20, 2022
@andylizi andylizi deleted the hide-type-hint-closure branch May 20, 2022 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants